package com.nhatviet.webservice.helpers;

public final class FlickrService
{
	/**
	 * URL common
	 */
	public static final String	URL						= "http://api.flickr.com/services/rest/?";
	/**
	 * Format receiving file
	 */
	public static final String	FORMAT_XML				= "rest";
	public static final String	FORMAT_JSONP			= "json";
	public static final String	FORMAT_JSON				= "json&nojsoncallback=1";
	public static final String	FORMAT_PHP				= "php_serial";
	/**
	 * Distance units
	 */
	public static final String	UNIT_KILOMETER			= "km";
	public static final String	UNIT_MILE				= "mi";
	/**
	 * Size suffixes
	 * 
	 * s small square 75x75; q large square 150x150; t thumb-nail, 100 on
	 * longest side; m small, 240 on longest side; n small, 320 on longest side
	 * - medium, 500 on longest side; z medium 640, 640 on longest side; c
	 * medium 800, 800 on longest side; b large, 1024 on longest side; o
	 * original image, either a jpg, gif or png, depending on source format
	 */
	public static final String	SIZE_SUFFIX_SMALL_QUARE	= "s";
	public static final String	SIZE_SUFFIX_LARGE_QUARE	= "q";
	public static final String	SIZE_SUFFIX_THUMBNAIL	= "t";
	public static final String	SIZE_SUFFIX_SMALL_240	= "m";
	public static final String	SIZE_SUFFIX_SMALL_320	= "n";
	public static final String	SIZE_SUFFIX_MEDIUM_500	= "";
	public static final String	SIZE_SUFFIX_MEDIUM_640	= "z";
	public static final String	SIZE_SUFFIX_MEDIUM_800	= "c";
	public static final String	SIZE_SUFFIX_LARGE		= "b";
	public static final String	SIZE_SUFFIX_ORIGINAL	= "o";

	/**
	 * @param methodStr
	 *            : flickr.X.Y
	 * @param apiKey
	 *            :
	 * @param formatReceiveStr
	 *            : rest <xml>, json <jsonp>, json&nojsoncallback=1 <json>,
	 *            php_serial <php>
	 */
	public static String getURL(String methodStr, String apiKeyStr, String formatReceiveStr)
	{
		return URL + "method=" + methodStr + "&api_key=" + apiKeyStr
				+ "&format=" + formatReceiveStr;
	}

	public static String getURL(String methodStr, String apiKeyStr, String latitudeStr, String longitudeStr, String formatReceiveStr)
	{
		return URL + "method=" + methodStr + "&api_key=" + apiKeyStr + "&lat="
				+ latitudeStr + "&lon=" + longitudeStr + "&format="
				+ formatReceiveStr;
	}

	public static String getURL(String methodStr, String apiKeyStr, String latitudeStr, String longitudeStr, String radiusStr, String radiusUnitStr, String formatReceiveStr)
	{
		return URL + "method=" + methodStr + "&api_key=" + apiKeyStr + "&lat="
				+ latitudeStr + "&lon=" + longitudeStr + "&radius=" + radiusStr
				+ "&radius_units=" + radiusUnitStr + "&format="
				+ formatReceiveStr;
	}

	/**
	 * Get URL of a photo
	 * 
	 * @param idStr
	 *            id of the photo
	 * @param serverIDStr
	 *            id of the server of the photo
	 * @param farmIDStr
	 *            id of the farm
	 * @param secretStr
	 *            secret number
	 * @return URL
	 */
	public static String getURLPhoto(String idStr, String serverIDStr, String farmIDStr, String secretStr)
	{
		return "http://farm" + farmIDStr + ".staticflickr.com/" + serverIDStr
				+ "/" + idStr + "_" + secretStr + ".jpg";
	}

	/**
	 * Get URL of a photo
	 * 
	 * @param idStr
	 *            id of the photo
	 * @param serverIDStr
	 *            id of the server of the photo
	 * @param farmIDStr
	 *            id of the farm
	 * @param secretStr
	 *            secret number
	 * @param sizeSuffixStr
	 *            the size suffix
	 * @return URL
	 */
	public static String getURLPhoto(String idStr, String serverIDStr, String farmIDStr, String secretStr, String sizeSuffixStr)
	{
		return "http://farm" + farmIDStr + ".staticflickr.com/" + serverIDStr
				+ "/" + idStr + "_" + secretStr + "_" + sizeSuffixStr + ".jpg";
	}

}
